﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ChinaDynastyTours.Controls;
using ChinaDynastyTours.Helpers;
using DevExpress.XtraGrid.Views.Grid;

namespace ChinaDynastyTours.Views
{
    public partial class CommissionDetailistForm : DevExpress.XtraEditors.XtraForm
    {

        public CommissionDetailistForm()
        {
            InitializeComponent();
        }


        private void CommissionFinanceVerifyForm_Load(object sender, EventArgs e)
        {
            #region 初始化查询条件，并首次查询

            //默认为上月1日起，下下月1日止
            dateStart.EditValue = DateTime.Parse(string.Format("{0}-{1}-01", DateTime.Now.Month > 1 ? DateTime.Now.Year : DateTime.Now.Year - 1, DateTime.Now.Month > 1 ? DateTime.Now.Month - 1 : 12));
            dateEnd.EditValue = DateTime.Parse(string.Format("{0}-{1}-01", DateTime.Now.Year + DateTime.Now.Month / 11, (DateTime.Now.Month + 1) % 12 + 1));

            //初始化组团人列表
            ownerALookUpEdit.DataSource = UserInfoCtrl.GetUserInfoData();

            //初始化部门列表
            departmentLookupEdit.DataSource = BaseInfoCtrl.GetDepartmentData(0);

            //初始化组团人列表
            shopLookUpEdit.DataSource = ShopCtrl.GetShopNameAndIDInfo();

            guideCombox.Items.AddRange(UserInfoCtrl.GetAllUserNameInRole("导游"));

            btnRefresh.PerformClick();
        }
            
        #endregion
        //查询团数据
        private void btnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DateTime dateStart = DateTime.Parse(this.dateStart.EditValue.ToString());
            DateTime dateEnd = DateTime.Parse(this.dateEnd.EditValue.ToString());

            string shopId = tbShop.EditValue == null ? "" : tbShop.EditValue.ToString();
            string departmentId=tbDepartment.EditValue == null ? "" : tbDepartment.EditValue.ToString();
            string ownerA=tbOwnerA.EditValue == null ? "" : tbOwnerA.EditValue.ToString();
            string guideName = tbGuideName.EditValue == null ? "" : tbGuideName.EditValue.ToString();

            commissionGridControl.DataSource = CommissionCtrl.GetCommissionDetailistData(dateStart, dateEnd,departmentId , shopId, ownerA, guideName);
                        

        }
    }
}